package com.qu.waibao.my.activity;

import android.content.Intent;
import android.opengl.ETC1;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.qu.waibao.AppConfig;
import com.qu.waibao.R;
import com.qu.waibao.account.XiuAuthonticActivity;
import com.qu.waibao.baidu.LocationUtils;
import com.qu.waibao.base.BaseActivity;
import com.qu.waibao.bean.Image;
import com.qu.waibao.bean.UserInfor;
import com.qu.waibao.interf.XnetCallBack;
import com.qu.waibao.network.ActionUtil;
import com.qu.waibao.network.NetManager;
import com.qu.waibao.widget.TweetPicturesLayout;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;

public class XiuAuthenticActivity extends BaseActivity implements View.OnClickListener{
    @BindView(R.id.tv_title)
    TextView tv_title;
    @BindView(R.id.tv_sure)
    TextView tv_sure;
    @BindView(R.id.iv_publish)
    ImageView iv_publish;
    @BindView(R.id.et_name)
    TextView et_name;
    @BindView(R.id.et_phone)
    TextView et_phone;
    @BindView(R.id.et_address)
    TextView et_address;
    @BindView(R.id.et_card)
    TextView et_card;
    @BindView(R.id.tv_check_state)
    TextView tv_check_state;
    @BindView(R.id.iv_bg)
    ImageView iv_bg;
    @BindView(R.id.mTweetPicturesLayout)
    TweetPicturesLayout mTweetPicturesLayout;
    private UserInfor userInfor;

    @Override
    protected boolean initBundle(Bundle bundle) {
        if(bundle != null){
            userInfor = (UserInfor) bundle.getSerializable("UserInfor");
        }
        return super.initBundle(bundle);
    }

    @Override
    protected int getContentView() {
        return R.layout.activity_xiu_authentic;
    }

    @Override
    protected void initWidget() {
        super.initWidget();
        tv_title.setText("认证资料");
        tv_sure.setText("修改");
        tv_sure.setVisibility(View.VISIBLE);
        iv_publish.setVisibility(View.GONE);
        if(userInfor != null){
            et_name.setText(userInfor.getName());
            et_phone.setText(userInfor.getPhone());
            et_address.setText(userInfor.getAddress());
            et_card.setText(userInfor.getIdcard());
            if(!TextUtils.isEmpty(userInfor.getImgs())){
                String[] images = userInfor.getImgs().split(",");
                mTweetPicturesLayout.setImage(images);
            }

            if(userInfor.getState_check().equals("1")){
                tv_check_state.setText("审核中");
            }else if(userInfor.getState_check().equals("2")){
                tv_check_state.setText("审核通过");
                iv_bg.setImageResource(R.drawable.rzzl_bannertongguo);
            }else if(userInfor.getState_check().equals("3")){
                tv_check_state.setText("审核失败");
                iv_bg.setImageResource(R.drawable.rzzl_banner_shibai);
            }
        }
    }

    @Override
    protected void onResume() {
        super.onResume();

    }

    @Override
    protected void initData() {
        super.initData();
    }

    @OnClick({R.id.ll_back,R.id.tv_sure})
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ll_back:
                finish();
                break;
            case R.id.tv_sure:
                Intent intent = new Intent(this, XiuAuthonticActivity.class);
                if(userInfor != null) {
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("UserInfor", userInfor);
                    intent.putExtras(bundle);
                }
                startActivity(intent);
                break;
        }
    }

}
